{
    let  [a, b, c]  = ["Hello", "world", "country"];
    console.log(a);   // Hello
    console.log(c);   // country

    let [d,[[e], f],[g]] = [1, [[2], 3],[4]];
    console.log(d, e, f, g);  // 1 2 3 4
    //console.log(h);  // h is not defined

    let [ , , m] = [ , 2, 3];
    console.log(m)   //3
    let [ , , n] = [, 2]
    console.log(n);  //undefined
    let [o, ...p] = [1, 2, 3, 4, 5]
    console.log(o);  //1
    console.log(p)   //[2, 3, 4, 5]

    let [q, r, ...s] = [1, 2, 3, 4, 5]
    console.log(q, r, s);  //1 2 [ 3, 4, 5 ]

    //let [t, ...u, ...v] = [1, 2, 3, 4, 5, 6]
    //console.log(t, u, v);  //SyntaxError: Rest element must be last element in array

    let [w, x, ...y] = [1]
    console.log(w, x, y);  //1 undefined []
    console.log("-------------------------------------------------------------")
}


{
    let [i, [j, k],[l]] = [5, [6], [7]];
    console.log(1, j, k, l)   //1 6 undefined 7
    console.log("-------------------------------------------------------------")
}

/*{
    let [a, [b, [c, d]]] = [1, [2, [3, 4, 5], 6]];
    console.log(a, b, c, d);  //1, 2, 3, 4

    let [e, [f,[g, h]]] = [1, [3, 4, [5, 6, 7]]]
    console.log(e, f, g, h);  //   let [e, [f,[g, h]]] = [1, [3, 4, [5, 6, 7]]]
                              //            ^
                              //   TypeError: undefined is not a function
}*/

{
    let [a, b, c] = new Set([1, 2, 3]);
    console.log(a, b,c);  //1, 2, 3
    console.log("-------------------------------------------------------------")
}
{
    let [a = 1] = [2];
    console.log(a);  //2
    let [b = 1, c = 2] = [];
    console.log(b, c);   //1, 2
    let [d, e = 3] = [1]
    console.log(d, e);   //1, 3
    let [f = 1] = [undefined];
    console.log(f);  //1
    let [g = 2] = [null];
    console.log(g)    // null

    let [h = fun1()] = [1]
    console.log('h'); //h

    let [i = fun1()] = [];
    console.log(i);  // come here

    console.log("-------------------------------------------------------------")
}
function fun1(){
    return 'come here';
}

{
    let [a = 1, b = a] = [];
    console.log(a, b)       //1, 1
    let [c = 1, d = c] = [3]
    console.log(c, d);      //3, 3
    let [e = 1, f = e] = [5, 10]
    console.log(e, f);     // 5, 10
    let [g = h, h = 1] = [3, 6]
    console.log(g, h)      // 3, 6
 // let [i = j, j = 1] = [];
 // console.log(i, j);     //ReferenceError: j is not defined

}

